import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import { ExtendRoute } from '@/types/ExtendRoute'
import Layout from '@/layout/index.vue'
// 扩展继承属性
// interface extendRoute {
//   hidden?:boolean
// }

// 异步组件
export const asyncRoutes = [
]
/**
 * path ==> 路由路径
 * name ==> 路由名称
 * component ==> 路由组件
 * redirect ==> 路由重定向
 * alwaysShow ==> 如果设置为true，将始终显示根菜单，无论其子路由长度如何
 * hidden ==> 如果“hidden:true”不会显示在侧边栏中（默认值为false）
 * keepAlive ==> 设为true 缓存
 * meta ==> 路由元信息
 * meta.title ==> 路由标题
 * meta.icon ==> 菜单icon
 * meta.affix ==> 如果设置为true将会出现在 标签栏中
 * meta.breadcrumb ==> 如果设置为false，该项将隐藏在breadcrumb中（默认值为true）
 */
export const constantRoutes: Array<RouteRecordRaw&ExtendRoute> = [
  {
    path: '/',
    name: 'layout',
    component: Layout,
    redirect: '/home',
    meta: { title: '首页', icon: 'borrow' },
    children: [
      {
        path: '/home',
        component: () => import('@/views/index/index.vue'),
        name: 'home',
        meta: { title: '首页', icon: 'House', affix: true }
      }
    ]
  },
  {
    path: '/',
    name: 'layout',
    component: Layout,
    redirect: '/home',
    meta: { title: '首页', icon: 'borrow' },
    children: [
      {
        path: '/home',
        component: () => import('@/views/index/index.vue'),
        name: 'home',
        meta: { title: '首页', icon: 'House', affix: true }
      }
    ]
  }
]

const router = createRouter({
  routes: constantRoutes,
  history: createWebHistory('/rpt/')
})

export default router
